package class21To30;

import java.io.*;
import java.util.Arrays;
import java.util.PriorityQueue;

public class MaxCover {

    public static int MAX_N = 10005;

    public static int n;

    public static int[][] line = new int[MAX_N][2];

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        while (in.nextToken() != StreamTokenizer.TT_EOF) {
            n = (int) in.nval;
            for (int i = 0; i < n; i++) {
                in.nextToken();
                line[i][0] = (int) in.nval;
                in.nextToken();
                line[i][1] = (int) in.nval;
            }
            out.println(maxCover());
        }
        out.flush();
        out.close();
        br.close();
    }

    private static int maxCover() {
        PriorityQueue<Integer> heap = new PriorityQueue<>((a, b) -> a - b);
        Arrays.sort(line, 0, n, (a, b) -> a[0] - b[0]);
        heap.clear();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            while (!heap.isEmpty() && heap.peek() <= line[i][0]) {
                heap.poll();
            }
            heap.add(line[i][1]);
            ans = Math.max(ans, heap.size());
        }
        return ans;
    }
}
